Create Team V2 RestAPI giving "Name cannot be empty" error message

Hello -
I made several attempts to create a single Team using the V2 RESTApi, but unable to do so.

My curl statement is :
curl -X POST --header ‘Accept: application/vnd.pagerduty+json;version=2’ --header ‘Authorization: Token token=’ -d ‘{“team”: {“type”: “team”, “name” : “teamname”}}’ ‘https://api.pagerduty.com/teams

please help!!

hello! If you move the team fields out to the top level of your body, it should work. For example,

{“name” : “teamname”}

That should create a team with the name of “teamname”

Thanks; But, do you mean - instead of {“type”: “team”, “name”:“teamname”} I use this inline format instead - {“name”: “teamname”} and do not use either the type and or the description keys at all as the request schema instructs me to do so?

I tried that, I get the same error message “name cannot be empty”

I tried all combinations of the team json object, moving team, name, etc outside … none of them work… can you please help, this is urgent!

According to the API Explorer documentation the request schema should look like this -
{
“team”: {
“type”: “team”,
“name”: “Engineering”,
“description”: “The engineering team”
}
}

I did some investigating, and the missing piece is the Content-Type header. So, your full curl request (minus the token) looks like this:

curl -X POST -H 'Accept:application/vnd.pagerduty+json;version=2' -H "Content-Type: application/json" -H 'Authorization:Token token=' -d '{"name" : "teamname-cli"}}' https://api.pagerduty.com/teams

You can also set a description if you would like, but it’s not required.

1 Like

Isnt the content type json a default for PagerDuty API calls…? I dont need to specify that… When i make the GET calls without the content type it works fine…

Ok; This worked…!! Phew!

strange observations -

  1. it does not like the use of --h for the content type and am forced to use -H
  2. the request schema I am forced to use here “name” : “teamname” inside curly braces is completely different from the documented API request schema…

Thanks for your help! Appreciate it very much …

You’re welcome! Glad to help. And, I agree that the documentation is in need of an update. That is definitely on our list of things to address.

1 Like